<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>List for Employee</title>
    <link rel="stylesheet" href="${pageContext.request.contextPath}/static/css/index_work.css">
    <script type="text/javascript" src="${pageContext.request.contextPath}/static/js/jquery-1.8.2.min.js"></script>
    <script type="text/javascript">
        $(function () {
            // 为超链接绑定单击事件
            $(".delete").click(function () {
                // 为表单的action属性赋值
                $("#btnForm").prop("action",$(this).prop("href")).submit();
                // 取消自动提交
                return false;
            }) ;
        });
    </script>
</head>
<body>
<table>
    <tr>
        <th colspan="6">Employee Table</th>
    </tr>
    <tr>
        <th>用户ID</th>
        <th>LastName</th>
        <th>Email</th>
        <th>gender</th>
        <th>Department</th>
        <th>option(<a href="${pageContext.request.contextPath}/toAdd">Add</a>)</th>
    </tr>
    <c:forEach var="employee" items="${requestScope.employeeCollection}">
        <tr>
            <td>${pageScope.employee.id}</td>
            <td>${pageScope.employee.lastName}</td>
            <td>${pageScope.employee.email}</td>
            <td>${pageScope.employee.gender}</td>
            <td>${pageScope.employee.department.id}</td>
            <td>
                <a href="${pageContext.request.contextPath}/toUpdate/${pageScope.employee.id}">修改</a>
                <a class="delete" href="${pageContext.request.contextPath}/delete/${pageScope.employee.id}">删除</a>
            </td>
        </tr>
    </c:forEach>
</table>
<%--要发送delete请求，必须得先发送post，只能通过表单提交--%>
<form action="" id="btnForm" method="post">
    <input type="hidden" name="_method" value="delete">
</form>
</body>
</html>
